package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.EvViolation;
import com.ruoyi.system.service.IEvViolationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 违规管理Controller
 * 
 * @author wtd
 * @date 2025-11-15
 */
@RestController
@RequestMapping("/system/violationofwtd")
public class EvViolationController extends BaseController
{
    @Autowired
    private IEvViolationService evViolationService;

    /**
     * 查询违规管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:violationofwtd:list')")
    @GetMapping("/list")
    public TableDataInfo list(EvViolation evViolation)
    {
        startPage();
        List<EvViolation> list = evViolationService.selectEvViolationList(evViolation);
        return getDataTable(list);
    }

    /**
     * 导出违规管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:violationofwtd:export')")
    @Log(title = "违规管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EvViolation evViolation)
    {
        List<EvViolation> list = evViolationService.selectEvViolationList(evViolation);
        ExcelUtil<EvViolation> util = new ExcelUtil<EvViolation>(EvViolation.class);
        util.exportExcel(response, list, "违规管理数据");
    }

    /**
     * 获取违规管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:violationofwtd:query')")
    @GetMapping(value = "/{violationId}")
    public AjaxResult getInfo(@PathVariable("violationId") Long violationId)
    {
        return success(evViolationService.selectEvViolationByViolationId(violationId));
    }

    /**
     * 新增违规管理
     */
    @PreAuthorize("@ss.hasPermi('system:violationofwtd:add')")
    @Log(title = "违规管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EvViolation evViolation)
    {
        return toAjax(evViolationService.insertEvViolation(evViolation));
    }

    /**
     * 修改违规管理
     */
    @PreAuthorize("@ss.hasPermi('system:violationofwtd:edit')")
    @Log(title = "违规管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EvViolation evViolation)
    {
        return toAjax(evViolationService.updateEvViolation(evViolation));
    }

    /**
     * 删除违规管理
     */
    @PreAuthorize("@ss.hasPermi('system:violationofwtd:remove')")
    @Log(title = "违规管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{violationIds}")
    public AjaxResult remove(@PathVariable Long[] violationIds)
    {
        return toAjax(evViolationService.deleteEvViolationByViolationIds(violationIds));
    }
}
